import { axios } from "@/request/request";
const InspireCloud = require('@byteinspire/js-sdk')
const serviceId = 'qcljo8'; 
const inspirecloud = new InspireCloud({ serviceId });

/**
 * 文件分片上传
 * @method uploadFileSplice
 * @param {Blob}  myFile 文件类型
 * @param {Number} hash 文件分片索引
 * @param {String} fileName 文件名称
 * 
 * @return {Array} blobArrays 返回的分片文件内容
 */

export async function uploadFileSplice(formData){
    let data = await inspirecloud.run('uploadFileSplice',formData,{
        headers: {
            'content-type': 'multipart/form-data',
        },
    })
    return Promise.resolve(data)
}


/**
 * 合并分片文件
 * @method mergeFile
 * @param {Array}  blobArrays 分片文件数组
 * 
 */

export const mergeFile = (params) => {
    return axios({
      url: "/mergeFile",
      method: "post",
      data: params,
    });
};


/**
 * 删除分片文件
 * @method deleteSpliceFile
 * @param {Array}  blobArrays 分片文件数组
 * 
 */

export const deleteSpliceFile = (params) =>{
    return axios({
        url: "/deleteSpliceFile",
        method: "post",
        data: params,
      });
}
